package book;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockUninterruptiblyTest implements Runnable{

	Lock lock = new ReentrantLock();
	Condition condition = lock.newCondition();

	@Override
	public void run() {

		lock.lock();
		try {
			System.out.println("wait begin");
//			try {
//				condition.await();
//			} catch (InterruptedException e) {
//				e.printStackTrace();
//			}
			condition.awaitUninterruptibly(); //不能中断的休眠
			System.out.println("wait end");
		} finally {
			lock.unlock();
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		
		ReentrantLockUninterruptiblyTest lockTask = new ReentrantLockUninterruptiblyTest();
		Thread t = new Thread(lockTask);
		t.start();
		Thread.sleep(1000);
		t.interrupt();
	}
}
